var db = require( '../db/db' );

const tableName = 'core.app_usage';

exports.insert = async function ( params ) {
    var sql = `INSERT INTO ${ tableName }(user_id, app_id, used_at) VALUES($1, $2, now())`;
    var params = [ params.userId, params.appId ];

    try {

        var result = await db.runSql( sql, params );

        if ( result ) {
            return result.rows;
        }
        return null;

    } catch ( e ) {
        console.error( "新增app使用信息出错" );
        return null;
    }
};
